<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
		<script type="text/javascript">
			onload = function(){
				i1.style.width="50px";
				i1.style.height="50px";
			}
			var x = 0;
		/* 	onclick = function(){
				x+=5;
				i1.style.marginLeft = x+"px";
			} */
			
			//开启定时器
			setInterval(function(){
				if(x>=400){
					x=0;
				}
				x+=5;
				i1.style.marginLeft = x+"px";
			},1000);
		</script>
	</head>
	<body>
		<img  id="i1" src="../imgs/a.jpg">
	</body>
</html>